package com.jinghao.tws.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jinghao.core.common.controller.JingHaoBaseController;
import com.jinghao.tws.entity.WvCamera;
import com.jinghao.tws.entity.WvCamera.EWvCamera;
import com.jinghao.tws.entity.WvPallet;
import com.jinghao.tws.service.IWvCameraService;

@Controller
@Scope("prototype")
@RequestMapping(value = "/app/tws/WvCamera")
public class WvCameraController extends JingHaoBaseController<WvCamera> {
	//==================定制内容开始======================
//在这里修改代码
	
	/**
	 * 查询所有摄像头信息
	 * @param  
	 */
	@ResponseBody
	@RequestMapping(value = "/listWvCamera",method = RequestMethod.GET) 
	public Map<String, Object> listWvCamera(@ModelAttribute("model") WvCamera model){
		this.getWvCameraService().listWvCamera(model);
        return model.getListJson();   
	} 
	/**
	 * 查询所有摄像头信息（公共）
	 * @param  
	 */
	@ResponseBody
	@RequestMapping(value = "/listWvCameraAll",method = RequestMethod.GET) 
	public Map<String, Object> listWvCameraAll(@ModelAttribute("model") WvCamera model){
		this.getWvCameraService().listWvCameraAll(model);
        return model.getJson();   
	} 
	/**
	 * 增加摄像头信息
	 * @param  
	 */
	@ResponseBody
	@RequestMapping(value = "/addWvCamera",method = RequestMethod.POST) 
	public Map<String, Object> addWvCamera(@ModelAttribute("model") WvCamera model,@RequestBody Map<String,Object> map){
		model.setObjMap(map);
		this.getWvCameraService().addWvCamera(model);
        return model.getJson();   
	} 
	
	/**
	 * 修改摄像头信息
	 * @param  
	 */
	@ResponseBody
	@RequestMapping(value = "/updateWvCamera",method = RequestMethod.POST) 
	public Map<String, Object> updateWvCamera(@ModelAttribute("model") WvCamera model,@RequestBody Map<String,Object> map){
		model.setObjMap(map);
		this.getWvCameraService().updateWvCamera(model);
        return new WvPallet().getJson();   
	}
	
 
	
	
	/**
	（批量）启用摄像头信息

	@param WvCameraService
	 */
	@ResponseBody
	@RequestMapping(value = "/updateEnableWvCamera",method = RequestMethod.GET) 
	public Map<String,Object> updateEnableWvCamera(@ModelAttribute("model") WvCamera model){
		 model.setStatus(EWvCamera.status_1.getKey()); 
		 this.getWvCameraService().updateWvCameraState(model);
		 return model.getJson();
	}

	/**
	（批量）禁用摄像头信息

	@param WvCameraService
	 */
	@ResponseBody
	@RequestMapping(value = "/updateDisableWvCamera",method = RequestMethod.GET) 
	public Map<String,Object> updateDisableWvCamera(@ModelAttribute("model") WvCamera model){
		 model.setStatus(EWvCamera.status_0.getKey()); 
		 this.getWvCameraService().updateWvCameraState(model);
		 return model.getJson();
	}

	/**
	（批量）删除摄像头信息

	@param WvCameraService
	 */
	@ResponseBody
	@RequestMapping(value = "/updateDeleteWvCamera",method = RequestMethod.GET) 
	public Map<String,Object> updateDeleteWvCamera(@ModelAttribute("model") WvCamera model){
		 model.setStatus(EWvCamera.status_2.getKey()); 
		 this.getWvCameraService().updateWvCameraState(model);
		 return model.getJson();
	}
	//==================定制内容结束======================

	@Autowired
	public void setWvCameraService(IWvCameraService wvCameraService) {
		super.setIJingHaoBaseService(wvCameraService);
	}

	public IWvCameraService getWvCameraService() {
		return (IWvCameraService) super.getIJingHaoBaseService();
	}
}
